package com.svse.designPattern.compositereuseprinciple;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/7/26 10:04
 */
public class CRPTest2 {
    public static void main(String[] args) {
        Fuel fuel=new Fuel("汽油");
        Color color=new Color("白色");
        Car2 car2=new Car2(fuel,color);
        car2.run();
    }
}

class Car2{
    private static Fuel fuel;
    private  static Color color;

    public Car2(Fuel fuel, Color color) {
        this.fuel = fuel;
        this.color = color;
    }

    public Fuel getFuel() {
        return fuel;
    }

    public void setFuel(Fuel fuel) {
        this.fuel = fuel;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public static void run(){
        System.out.println("燃料为："+fuel.getName()+"颜色为："+color.getName()+"的车 在跑");
    }
}
class Fuel {
    private String name;

    public Fuel(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

class Color{
    private String name;

    public Color(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}